package com.tran.app.screen

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Column
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import com.tran.app.MyApp
import com.tran.app.R
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

@Composable
fun HomeScreen(modifier: Modifier){
    // 获取当前本地时间
    val currentTime = LocalDateTime.now()
    // 定义时间格式
    val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
    // 格式化当前时间
    val formattedTime = currentTime.format(formatter)
    val time by remember {
        mutableStateOf(formattedTime)
    }
    Column(modifier = modifier) {
        Text(text = "欢迎")
        Text(text = "用户名:"+MyApp.user)
        Text(text = "姓名:"+MyApp.realName)
        Text(text = "登录时间:$time")
        Image(painterResource(id = R.drawable.img), contentDescription = "图片")
    }
}